Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive probability of set_subtensor operations #7553

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Oct 29, 2024

The logprob for the following kind of graphs can now be derived:

import pytensor.tensor as pt
import pymc as pm

x = pt.zeros((3, 3))
y = x[[0, 1, 2], [0, 1, 2]].set(pm.Normal.dist(shape=(3,)))
z = y[[0, 1, 2], [2, 1, 0]].set(pm.StudentT.dist(nu=2, shape=(3,)))

pm.logp(z, pt.zeros((3, 3))).eval().round(2)
# array([[-0.92,  0.  , -1.04],
#        [ 0.  , -1.04,  0.  ],
#        [-1.04,  0.  , -0.92]])

@ricardoV94 ricardoV94 force-pushed the measurable_set_subtensor branch 3 times, most recently from 7eb43a1 to 8824944 Compare October 29, 2024 16:22
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 94.94949% with 5 lines in your changes missing coverage. Please review.

Project coverage is 92.87%. Comparing base (3057351) to head (75cf84d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pymc/logprob/set_subtensor.py 94.11% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7553      +/-   ##
==========================================
+ Coverage   92.83%   92.87%   +0.04%     
==========================================
  Files         106      107       +1     
  Lines       17669    17749      +80     
==========================================
+ Hits        16403    16485      +82     
+ Misses       1266     1264       -2     
Files with missing lines Coverage Δ
pymc/logprob/__init__.py 100.00% <100.00%> (ø)
pymc/logprob/checks.py 100.00% <100.00%> (ø)
pymc/logprob/utils.py 97.14% <100.00%> (+4.67%) ⬆️
pymc/logprob/set_subtensor.py 94.11% <94.11%> (ø)

@ricardoV94
Copy link
Member Author

Should restrict to when updates do not depend on previous writes to the buffer. Otherwise logp is not as straightforward/always deriverable

@ricardoV94 ricardoV94 marked this pull request as draft November 5, 2024 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant